package com.lz.gmall.product.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.lz.gmall.common.result.Result;
import com.lz.gmall.product.entity.SpuSaleAttr;
import com.lz.gmall.product.service.SpuSaleAttrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/admin/product")
@Api(tags = "销售属性")
public class SpuSaleAttrController {

    @Autowired
    private SpuSaleAttrService spuSaleAttrService;

    /**
     * 根据spuId获取销售属性
     * @param spuId spu产品Id
     * @return
     */
    @GetMapping("/spuSaleAttrList/{spuId}")
    @ApiOperation("根据spuId获取销售属性")
    public Result<List<SpuSaleAttr>> getSpuSaleAttrListBySpuId(@PathVariable(value = "spuId") Long spuId) {
        List<SpuSaleAttr> spuSaleAttrs = spuSaleAttrService.getSpuSaleAttrListBySpuId(spuId) ;
        return Result.ok(spuSaleAttrs) ;
    }
}
